package com.CmJava.tomcat.Server.service.container;

import com.CmJava.tomcat.Server.Component;
import com.CmJava.tomcat.Server.life.Lifecycle;
import com.CmJava.tomcat.Server.life.LifecycleState;
import com.CmJava.tomcat.Server.service.connector.Connector;

public class Context implements Lifecycle, Component {
    private String context="/";
    private Component child;
    private LifecycleState lifecycleState=LifecycleState.NEW;


    public Context(Component child) {
        this.child = child;
    }

    public Component getChild() {
        return child;
    }

    public void setChild(Component child) {
        this.child = child;
    }


    @Override
    public void init() {
        Wrapper wrapper = new Wrapper(null);
        wrapper.init();
        child=wrapper;
        lifecycleState=LifecycleState.INITIALIZED;
    }

    @Override
    public void start() {
        if (!Connector.request.getContext().equals(context)){
            return;
        }
        Wrapper wrapper = (Wrapper) child;
        wrapper.start();
    }

    @Override
    public void stop() {

    }

    @Override
    public void destroy() {

    }

    @Override
    public LifecycleState getState() {
        return null;
    }
}
